package com.example.administrator.commonlibrary.utils.arouter;

import android.content.Context;
import android.support.annotation.Keep;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.facade.service.SerializationService;
import com.alibaba.fastjson.JSON;

import java.lang.reflect.Type;

/**
 *
 *
 * @author
 * @version 此类的作用是 当你使用路由传送对象 序列化对象 没有此类会报错
 * @since
 */
@Keep
@Route(path = "/service/json")
public class JsonServiceImpl implements SerializationService {
   @Override
    public void init(Context context) {

    }

    @Override
    public <T> T json2Object(String text, Class<T> clazz) {
        return JSON.parseObject(text, clazz);
    }

    @Override
    public String object2Json(Object instance) {
        return JSON.toJSONString(instance);
    }

    @Override
    public <T> T parseObject(String input, Type clazz) {
        return JSON.parseObject(input, clazz);
    }
}
